package model

// StyleSpecification mapbox style
type StyleSpecification struct {
	Version    int                      `json:"version"`
	Name       string                   `json:"name,omitempty"`
	Metadata   interface{}              `json:"metadata,omitempty"`
	Center     []float64                `json:"center,omitempty"`
	Zoom       float64                  `json:"zoom,omitempty"`
	Bearing    int                      `json:"bearing,omitempty"`
	Pitch      int                      `json:"pitch,omitempty"`
	Light      LightSpecification       `json:"light,omitempty"`
	Terrain    TerrainSpecification     `json:"terrain,omitempty"`
	Fog        FogSpecification         `json:"fog,omitempty"`
	Sources    map[string]MapboxSource `json:"sources"`
	Sprite     string                   `json:"sprite,omitempty"`
	Glyphs     string                   `json:"glyphs,omitempty"`
	Transition TransitionSpecification  `json:"transition,omitempty"`
	Layers     []*LayerSpecification    `json:"layers"`
}

// LightSpecification A style's light property provides a global light source for that style.
type LightSpecification struct {
	// Anchor map or viewport
	Anchor   string    `json:"anchor,omitempty"`
	Position []float64 `json:"position,omitempty"`
	Color    string    `json:"color,omitempty"`

	// Intensity Optional number between 0 and 1 inclusive
	Intensity float64 `json:"intensity,omitempty"`
}

// TerrainSpecification A style's terrain property is a global modifier that elevates
// layers and markers based on a DEM data source.
type TerrainSpecification struct {
	Source       string `json:"source"`
	Exaggeration int    `json:"exaggeration,omitempty"`
}

// FogSpecification A style's fog property is a global effect that improves depth
// perception by fading out distant objects.
type FogSpecification struct {
	Color        string    `json:"color,omitempty"`
	Range        []float64 `json:"range,omitempty"`
	HorizonBlend float64   `json:"horizon-blend,omitempty"`
}

type IMapboxSource interface {
	Type() string
}

type MapboxSource struct {
	SourceType string `json:"type"`
}

func (m *MapboxSource) Type() string {
	return m.SourceType
}

// TransitionSpecification A transition property controls timing for the interpolation
// between a transitionable style property's previous value and new value
type TransitionSpecification struct {
	Duration int `json:"duration,omitempty"`
	Delay    int `json:"delay,omitempty"`
}

// LayerSpecification A style's layers property lists all the layers available in that style
type LayerSpecification struct {
	ID          string                 `json:"id"`
	Type        string                 `json:"type"`
	Filter      []string               `json:"filter,omitempty"`
	Layout      map[string]interface{} `json:"layout,omitempty"`
	MaxZoom     float64                `json:"maxzoom,omitempty"`
	Metadata    interface{}            `json:"metadata,omitempty"`
	MinZoom     float64                `json:"minzoom,omitempty"`
	Paint       map[string]interface{} `json:"paint,omitempty"`
	Source      string                 `json:"source,omitempty"`
	SourceLayer string                 `json:"source-layer,omitempty"`
}
